.row-fluid
  %hr.hr-widget

.row-fluid
  %h4 Data to Import

.row-fluid
  #sampleData.span12
    -if @messages.present?
      -@messages.each do |m|
        %p.label-warning
          =m
      %br

    -if @errors.any?
      %p.label-warning
        See specific errors below
      %br

    %table.ggrc-table{:cellspacing => "0", :cellpadding => "0"}
      %col{:style => "width:9%"}
      %col{:style => "width:5%"}
      %col{:style => "width:12%"}
      %col{:style => "width:12%"}
      %col{:style => "width:12%"}
      %col{:style => "width:12%"}
      %col{:style => "width:15%"}
      %col{:style => "width:14%"}
      %col{:style => "width:19%"}
      %thead
        %tr
          %th Request Type
          %th PBC Control Code
          %th PBC Control Description
          %th Request
          %th Notes
          %th Test
          %th Internal Assignee
          %th Auditor Contact
          %th Date Requested
      %tbody
        %tr
          %td{:colspan => "9", :cellspacing => "0", :cellpadding => "0"}
            .inner-table
              %table.inner-ggrc-table{:cellspacing => "0", :cellpadding => "0"}
                %col{:style => "width:9%"}
                %col{:style => "width:5%"}
                %col{:style => "width:12%"}
                %col{:style => "width:12%"}
                %col{:style => "width:12%"}
                %col{:style => "width:12%"}
                %col{:style => "width:15%"}
                %col{:style => "width:14%"}
                %col{:style => "width:9%"}
                %tbody
                  -columns = %w(type_id|type_name pbc_control_code pbc_control_desc request notes test company_responsible auditor_responsible date_requested)
                  -@requests.each_with_index do |req, i|
                    %tr{ :class => (i % 2 == 0 ? :odd : :even) }
                      -columns.each do |column_name|
                        -if column_name.include?('|')
                          -column_name, display_name = column_name.split('|')
                        -else
                          -display_name = column_name
                        %td{ :class => ( (@errors[i].present? && @errors[i][column_name].present?) ? 'member-failure' : ((@warnings[i].present? && @warnings[i][column_name].present?) ? 'member-warning' : '' ) ) }
                          =req.send(display_name)
                          -if @errors[i].present? && @errors[i][column_name].present?
                            .help-inline=@errors[i][column_name].join(', ')
                          -if @warnings[i].present? && @warnings[i][column_name].present?
                            .help-inline=@warnings[i][column_name].join(', ')

    Showing 1 to #{@requests.size} of #{@requests.size} entries

%br

.row-fluid
  -if params[:confirm].blank?
    .span8
      =link_to "Cancel", flow_pbc_list_path(@pbc_list), :class => "btn btn-large"
    .span1
      &nbsp;
    .span3
      -if @errors.any?
        =submit_tag "Correct Errors Before Proceeding", :class => %w(btn btn-large btn-warning pull-right), :name => 'confirm', :disabled => true
      -elsif @messages.any? || (@warnings.any? { |k,v| v.present? })
        =submit_tag "Proceed With Caution", :class => %w(btn btn-large btn-warning pull-right), :name => 'confirm'
      -else
        =submit_tag "Finish Importing", :class => %w(btn btn-large btn-success pull-right), :name => 'confirm'
  -else
    .span12
      Import of
      =link_to "PBC List Requests", flow_pbc_list_path(@pbc_list)
      is done.

